package com.gxa.weixing.core.util;



import com.gxa.weixing.core.common.JsonResult;

import java.util.Map;

/**
 * @author lijianmin
 * @date 2021/12/06  16:27:36
 */
public class ReturnJsonResultUtil {
    public static Map<String, Object> ReturnJsonResultUtil(Object object, String message) {
        JsonResult jsonResult = new JsonResult();
        if (object instanceof Boolean) {
            if (Boolean.TRUE.equals(Boolean.parseBoolean(object.toString()))) {
                jsonResult.setCode("1");
                jsonResult.setMsg(message + "成功！");
            } else {
                jsonResult.setCode("0");
                jsonResult.setMsg(message + "失败！");
            }
        } else if (object instanceof Integer) {
            if (Integer.parseInt(object.toString()) <= 0) {
                jsonResult.setCode("0");
                jsonResult.setMsg(message + "失败!");
            } else {
                jsonResult.setCode("1");
                jsonResult.setMsg(message + "成功!");
            }
        } else {
            if (object == null) {
                jsonResult.setCode("0");
                jsonResult.setMsg(message + "失败!");
            } else {
                jsonResult.setCode("1");
                jsonResult.setMsg(message + "成功!");
            }
        }
        return jsonResult.getDataMap();
    }
}
